﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MsdnMag;
using System.Runtime.InteropServices;
using System.IO;
using System.Windows.Forms;

namespace PostscriptPreviewHandler
{
    /// <summary>
    /// Will run a preview for post script files so they can be seen in outlook or from the base
    /// explorer.
    /// </summary>
    [PreviewHandler("Postscript/Encapsulated Postscript Preview Handler", ".eps;.ps",
                    "{6593B5B8-1E2E-4482-8B67-3528000B57AD}")]
    [ProgId("MsdnMag.ZipPreviewHandler")]
    [Guid("853f35e3-bd13-417b-b859-1df25be6c834")]
    [ClassInterface(ClassInterfaceType.None)]
    [ComVisible(true)]
    public sealed class PSPreviewHandler : FileBasedPreviewHandler
    {
        protected override PreviewHandlerControl CreatePreviewHandlerControl()
        {
            return new PSPreviewHandlerControl();
        }

        private sealed class PSPreviewHandlerControl :
            FileBasedPreviewHandlerControl
        {
            public override void Load(FileInfo file)
            {
                UIControls.PSPaneScroll pane = new UIControls.PSPaneScroll();
                pane.Dock = DockStyle.Fill;
                pane.BorderStyle = BorderStyle.None;

                Controls.Add(pane);

                pane.PSFile = file;
            }
        }
    }

}
